<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">

<div th:replace="include/header::head"></div>

<div th:replace="include/teacher_navbar::navbar(${loginTeacher})"></div>

<div class="container">
	<h1>
		<img th:src="@{/static/img/exam-teacher.png}" /> 上机考试管理
	</h1>

<div class="exam-form form-inline">
	<h4>编辑考试信息</h4>
	<input type="hidden" id="examId" name="id" th:value="${exam.id}" />
	考试名称：
	<input type="text" id="examName" name="ename" th:value="${exam.name}" />
	考试时间：
	<div class="controls input-append date" id="datetimepicker2" data-link-field="etime" >
		<input class="span2" type="text" th:value="${#dates.format(exam.time, 'yyyy-MM-dd HH:mm:ss')}" readonly="readonly"/>
		<span class="add-on"><i class="icon-remove"></i></span>
		<span class="add-on"><i class="icon-th"></i></span>
	</div>
	<input type="hidden" id="etime" name="etime" />
	<div class="control-group">
		<div class="controls">
			<label class="checkbox">
				<input type="checkbox" id="isAutoStart2" name="eautostart" th:checked="${exam.isAutostart}" /> 自动开始
			</label>
		</div>
	</div>
	<div class="control-group">
		<div class="controls">
			<button type="submit" id="examUpdate" name="action" class="btn btn-primary">修改</button>
		</div>
	</div>
</div>


	<form class="exam-form form-inline" id="upForm" th:action="@{/teacher/exam/upload}" enctype="multipart/form-data" method="post">
		<h4>上传试卷</h4>
		<input type="hidden" name="id" th:value="${exam.id}" />

		<div th:if="${exam.paper != null and exam.paper != ''}">
			<p class="exam-alert">
				已经上传过试卷，再次上传将导致原有试卷不可访问！
				<a class="btn" target="_blank" th:href="@{'/teacher/exam/download/' + ${exam.id}}">
					<i class="icon-download"></i>下载查看
				</a>
			</p>
			<input type="file" name="paper" />
			<input type="submit" id="updatePaper" class="btn btn-warning" value="更新" />
		</div>

		<div th:unless="${exam.paper != null and exam.paper != ''}">
			<input type="file" name="paper" />
			<input type="submit" id="uploadPaper" class="btn btn-primary" value="上传" />
		</div>

	</form>

	<form class="exam-form form-inline" th:action="@{'/teacher/student/' + ${exam.id} + '/1'}" method="get">
		<h4>导入学生名单</h4>
		<p>目前设定参加此次考试的学生人数：[[${studentCount}]]</p>
		<input type="submit" class="btn btn-primary" value="继续导入" />
	</form>


	<form class="exam-form form-inline" th:action="@{/teacher/exam/start}" method="post">
		<h4>开启考试</h4>
		<input type="hidden" name="id" th:value="${exam.id}" />

		<th:block th:if="${application.exam != null}">
			<p class="text-danger">考试（<span th:text="${application.exam.name}"></span>）正在进行中，本系统不允许同时进行多场考试。</p>
		</th:block>

		<th:block th:unless="${application.exam != null}">
			<th:block th:if="${!canStart}">
				<p class="text-danger">时间相差过多，不能开启考试。</p>
				<button type="submit" class="btn btn-danger btn-large disabled" onclick="return false"><i class="icon-off"></i> 开启</button>
			</th:block>

			<th:block th:if="${canStart}">
				<th:block th:if="${exam.paper} == null or ${exam.paper.isEmpty()}">
					<p class="text-warning">尚未上传试卷。</p>
					<button type="submit" class="btn btn-warning btn-large"><i class="icon-off"></i> 开启</button>
				</th:block>

				<th:block th:if="${exam.paper != null and !exam.paper.isEmpty()}">
					<button type="submit" class="btn btn-success btn-large"><i class="icon-off"></i> 开启</button>
				</th:block>
			</th:block>
		</th:block>
	</form>
</div>

<div th:replace="include/teacher_footer::footer"></div>
<script type="text/javascript">
$("#datetimepicker2").datetimepicker({
    format: "yyyy-mm-dd hh:ii",
    autoclose: true,
    todayBtn: true,
    minuteStep: 10,
    minView:0,
    pickerPosition:'bottom-left',
    language:'zh-CN'
});
</script>
